Here's the algorithm to get a star's position (star_x, star_y, star_z) and seed (star_seed) from its sector coordinates (sect_x, sect_y, sect_z). long is a 32-bit data type.

Note: This algorithm has been tested (In tests.cpp, compiles as a module to noctis, which tests three different algorithms), and also exists in modshare.hpp (for modules), and is used in FindStarAndTarget in noctis-2.cpp (which is used to look for a star when you target parsis coordinates). The main point of converting the algorithm to c++ was to have something easily usable in 32-bit programs, and something convertible to java and possibly other languages, etc.

	long star_x, star_y, star_z, xz, mixer;
	
	xz = sect_x + sect_z;
	star_x = (xz & 0x1ffff) + sect_x - 50000;
	if (star_x!=0) {
		star_y = ImulAndAdd(star_x, xz);
		mixer = xz + star_y;
		star_y = (star_y & 0x1ffff) + sect_y - 50000;
		if (star_y!=0) {
			star_z = ImulAndAdd(star_y, mixer);
			star_z = (star_z & 0x1ffff) + sect_z - 50000;
			if (star_z!=0) {
				short rarity = (((short)star_x) + ((short)star_y) + ((short)star_z));
				if ((rarity & rarity_factor) == 0) {
					//valid;
					star_seed = ((double)star_x)/100000*((double)star_y)/100000*((double)star_z)/100000;
				} else {
					//invalid;
				}
			}
		}
	}

ImulAndAdd is needed because BC3.1 has no 64-bit integer data types:

In C++ for BC3.1 (as a 16-bit dos program), where long is a 32-bit type:
long ImulAndAdd(long main, long secondary) {
	long result = 0;
	asm {
		db 0x66; mov dx, word ptr main
		db 0x66; mov ax, word ptr secondary
		db 0x66; imul dx
		db 0x66; add dx, ax
		db 0x66; mov word ptr result, dx
	}
	return result;
}
The 'imul' op multiplies eax times its argument, and stores the high dword (32 bits) in eax and the low dword in edx.

In C# or java, with long being a 64-bit type, and int being a 32-bit type:
Note: You may need to cast main and secondary to long before multiplying them.
int ImulAndAdd(int main, int secondary) {
	long tmpresult = main*secondary;
	return (int) ((tmpresult&0xffffffff)+((tmpresult>>32)&0xffffffff));
}
